package com.sicurezza.secUtility;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import android.content.Context;
import android.widget.Toast;

public class HashMaker {
	
	private byte[] key;
	private String algorithm;
	private Context context;
	
	public HashMaker(byte[] key, String algorithm, Context context) {
		super();
		this.key = key;
		this.algorithm = algorithm;
		this.context = context;
	}
	
	public String hashMake(){
		try {
			MessageDigest md;
			md = MessageDigest.getInstance(algorithm);
			md.update(this.key);
			return new String(md.digest());
		} catch (NoSuchAlgorithmException e) {
			Toast alertToast = Toast.makeText(context, "SHA non supportato, termino...", Toast.LENGTH_LONG);
			alertToast.show();
			return null;
		}
	}

}
